package com.fanqwz.hexieshe.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.fanqwz.hexieshe.Application;
import com.fanqwz.hexieshe.Navigator;
import com.fanqwz.hexieshe.dagger.component.ActivityComponent;
import com.fanqwz.hexieshe.dagger.component.DaggerActivityComponent;
import com.fanqwz.hexieshe.dagger.module.ActivityModule;

/**
 * Created by fanqw on 2017/6/30.
 */

public abstract class BaseActivity extends AppCompatActivity {
    ActivityComponent activityComponent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ((Application) getApplication()).getComponent().inject(this);
        activityComponent = DaggerActivityComponent.builder()
                .applicationComponent(((Application) getApplication()).getComponent())
                .activityModule(new ActivityModule(this))
                .build();
    }

    public abstract Navigator provideNavigator();

    public ActivityComponent getComponent() {
        return activityComponent;
    }
}
